<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let flag = true
      let num = +prompt('请输入一个数字')

      function Ishuiwen(num){
      let length = String(num).length
      // console.log(length)
      let str = 1
      for (let i = 1; i < length; i++) {
        str += '0'
      }
      // console.log(str);
      let str1 = '10'
      for (let i = 1; i <= length / 2; i++) {
        a = parseInt(num / str)
        b = num % str1
        if (a != b) {
          flag = false
          return  '不是回文数'
          break
        }
        num = num % str
        num = parseInt(num / str1)
        str = str / 100
      }

      if (flag) {
       return  '是回文数'
      }
    }

    console.log(Ishuiwen(num));
    </script>
  </body>
</html>
